/**
 *
 */
import Util;
import OpenApi;
import OpenApiUtil;
import EndpointUtil;

extends OpenApi;


init(config: OpenApi.Config){
  super(config);
  @endpointRule = 'regional';
  @endpointMap = {
    ap-northeast-2-pop = 'arms.aliyuncs.com',
    cn-beijing-finance-1 = 'arms.aliyuncs.com',
    cn-beijing-finance-pop = 'arms.aliyuncs.com',
    cn-beijing-gov-1 = 'arms.aliyuncs.com',
    cn-beijing-nu16-b01 = 'arms.aliyuncs.com',
    cn-edge-1 = 'arms.aliyuncs.com',
    cn-fujian = 'arms.aliyuncs.com',
    cn-haidian-cm12-c01 = 'arms.aliyuncs.com',
    cn-hangzhou-bj-b01 = 'arms.aliyuncs.com',
    cn-hangzhou-internal-prod-1 = 'arms.aliyuncs.com',
    cn-hangzhou-internal-test-1 = 'arms.aliyuncs.com',
    cn-hangzhou-internal-test-2 = 'arms.aliyuncs.com',
    cn-hangzhou-internal-test-3 = 'arms.aliyuncs.com',
    cn-hangzhou-test-306 = 'arms.aliyuncs.com',
    cn-hongkong-finance-pop = 'arms.aliyuncs.com',
    cn-huhehaote-nebula-1 = 'arms.aliyuncs.com',
    cn-qingdao-nebula = 'arms.aliyuncs.com',
    cn-shanghai-et15-b01 = 'arms.aliyuncs.com',
    cn-shanghai-et2-b01 = 'arms.aliyuncs.com',
    cn-shanghai-inner = 'arms.aliyuncs.com',
    cn-shanghai-internal-test-1 = 'arms.aliyuncs.com',
    cn-shenzhen-inner = 'arms.aliyuncs.com',
    cn-shenzhen-st4-d01 = 'arms.aliyuncs.com',
    cn-shenzhen-su18-b01 = 'arms.aliyuncs.com',
    cn-wuhan = 'arms.aliyuncs.com',
    cn-yushanfang = 'arms.aliyuncs.com',
    cn-zhangbei = 'arms.aliyuncs.com',
    cn-zhangbei-na61-b01 = 'arms.aliyuncs.com',
    cn-zhangjiakou-na62-a01 = 'arms.aliyuncs.com',
    cn-zhengzhou-nebula-1 = 'arms.aliyuncs.com',
    eu-west-1-oxs = 'arms.aliyuncs.com',
    me-east-1 = 'arms.aliyuncs.com',
    rus-west-1-pop = 'arms.aliyuncs.com',
  };

  checkConfig(config);
  @endpoint = getEndpoint('arms', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }
  
  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}

model CallChainInfo {
  additionalInfo?: string(name='AdditionalInfo'),
  appName?: string(name='AppName'),
  appType?: string(name='AppType'),
  children?: [
    CallChainInfo
  ](name='Children'),
  haveSpan?: boolean(name='HaveSpan'),
  logMap?: map[string]object(name='LogMap'),
  logTime?: long(name='LogTime'),
  parentSpanId?: string(name='ParentSpanId'),
  pid?: string(name='Pid'),
  regionId?: string(name='RegionId'),
  resultCode?: string(name='ResultCode'),
  rpc?: string(name='Rpc'),
  rpcId?: string(name='RpcId'),
  rpcType?: long(name='RpcType'),
  serverIp?: string(name='ServerIp'),
  span?: long(name='Span'),
  spanId?: string(name='SpanId'),
  tagMap?: map[string]string(name='TagMap'),
  traceId?: string(name='TraceId'),
}

model GrafanaWorkspace {
  commercial?: boolean(name='commercial'),
  deployType?: string(name='deployType'),
  description?: string(name='description'),
  endTime?: float(name='endTime', example='1652803200000'),
  gmtCreate?: float(name='gmtCreate', example='创建时间'),
  grafanaVersion?: string(name='grafanaVersion'),
  grafanaWorkspaceDomain?: string(name='grafanaWorkspaceDomain'),
  grafanaWorkspaceEdition?: string(name='grafanaWorkspaceEdition', example='experts_edition/advanced_edition/standard'),
  grafanaWorkspaceId?: string(name='grafanaWorkspaceId', example='g-thisisademo666'),
  grafanaWorkspaceIp?: string(name='grafanaWorkspaceIp', example='127.0.0.1:3000'),
  grafanaWorkspaceName?: string(name='grafanaWorkspaceName'),
  maxAccount?: string(name='maxAccount', example='10'),
  ntmId?: string(name='ntmId'),
  personalDomain?: string(name='personalDomain'),
  personalDomainPrefix?: string(name='personalDomainPrefix'),
  privateDomain?: string(name='privateDomain'),
  privateIp?: string(name='privateIp'),
  protocol?: string(name='protocol', example='http/https'),
  regionId?: string(name='regionId', example='cn-hangzhou'),
  resourceGroupId?: string(name='resourceGroupId'),
  shareSynced?: boolean(name='shareSynced'),
  snatIp?: string(name='snatIp', example='1.1.1.1'),
  status?: string(name='status', example='Starting/Running/Stop/DeleteSucceed'),
  tags?: [ 
    {
      key?: string(name='key'),
      value?: string(name='value'),
    }
  ](name='tags'),
  upgradeVersion?: [ string ](name='upgradeVersion'),
  userId?: string(name='userId', example='66666666'),
}

model GrafanaWorkspaceAccount {
  accountId?: long(name='accountId', example='1'),
  accountNotes?: string(name='accountNotes'),
  aliyunUid?: string(name='aliyunUid', example='131243781293'),
  aliyunUserName?: string(name='aliyunUserName', example='test'),
  gmtCreate?: float(name='gmtCreate', example='创建时间'),
  orgs?: [
    GrafanaWorkspaceUserOrg
  ](name='orgs'),
}

model GrafanaWorkspaceAlertNotification {
  id?: long(name='id', example='1'),
  isArms?: boolean(name='isArms', example='true'),
  isDefault?: boolean(name='isDefault', example='true'),
  name?: string(name='name', example='test'),
  sendReminder?: boolean(name='sendReminder', example='true'),
  settings?: string(name='settings', example='{}'),
  type?: string(name='type', example='Email'),
  uid?: string(name='uid', example='Xfdf******'),
}

model GrafanaWorkspaceArmsAlertConfig {
  armsAlertsEnable?: string(name='armsAlertsEnable', example='true'),
  armsAlertsWebhookUrl?: string(name='armsAlertsWebhookUrl'),
}

model GrafanaWorkspaceCustomDomain {
  cert?: string(name='cert', example='protocol为http时无需填写;'),
  date?: long(name='date', example='1688627798017'),
  domain?: string(name='domain', example='mydomain.com'),
  grafanaWorkspaceId?: string(name='grafanaWorkspaceId', example='grafana-cn-***********'),
  id?: long(name='id', example='1'),
  key?: string(name='key', example='protocol为http时无需填写;'),
  privateZone?: string(name='privateZone', example='true'),
  protocol?: string(name='protocol', example='https'),
  status?: string(name='status', example='CreateSucceed'),
  uri?: string(name='uri', example='/'),
}

model GrafanaWorkspaceDashboardReport {
  gmtCreate?: long(name='gmtCreate', example='1680861352600'),
  grafanaWorkspaceId?: string(name='grafanaWorkspaceId', example='grafana-cn-**********'),
  id?: long(name='id', example='1'),
  lastSendTime?: long(name='lastSendTime', example='1680861352600'),
  msg?: string(name='msg'),
  name?: string(name='name'),
  reportChannelTarget?: string(name='reportChannelTarget', example='******@aliyun.com'),
  reportChannelType?: string(name='reportChannelType', example='Email'),
  reportStyle?: string(name='reportStyle', example='Grid,Simple'),
  reportType?: string(name='reportType', example='Image'),
  status?: string(name='status'),
  triggerDay?: string(name='triggerDay', example='1'),
  triggerTime?: string(name='triggerTime', example='12:25'),
  triggerType?: string(name='triggerType', example='ByWeek'),
  url?: string(name='url', example='Dashboard URL'),
  userId?: string(name='userId'),
}

model GrafanaWorkspaceDataBackup {
  gmtCreate?: long(name='gmtCreate', example='1680861352600'),
  gmtModified?: long(name='gmtModified', example='1680861352600'),
  grafanaWorkspaceId?: string(name='grafanaWorkspaceId', example='grafana-cn-**********'),
  id?: long(name='id', example='1'),
  msg?: string(name='msg'),
  processName?: string(name='processName'),
  processStatus?: string(name='processStatus'),
  subType?: string(name='subType', example='User'),
  userId?: string(name='userId'),
}

model GrafanaWorkspaceIniBackup {
  ext?: string(name='ext'),
  gmtCreate?: long(name='gmtCreate', example='1680861352600'),
  gmtModified?: long(name='gmtModified', example='1680861352600'),
  grafanaWorkspaceId?: string(name='grafanaWorkspaceId', example='grafana-cn-**********'),
  id?: long(name='id', example='1'),
  msg?: string(name='msg'),
  processName?: string(name='processName'),
  processStatus?: string(name='processStatus'),
  subType?: string(name='subType', example='User'),
  userId?: string(name='userId'),
}

model GrafanaWorkspaceIniProperty {
  defaultValue?: string(name='defaultValue'),
  description?: string(name='description'),
  example?: string(name='example'),
  key?: string(name='key'),
  secret?: boolean(name='secret'),
  value?: string(name='value'),
}

model GrafanaWorkspaceIniSection {
  propertys?: [
    GrafanaWorkspaceIniProperty
  ](name='propertys'),
  section?: string(name='section'),
}

model GrafanaWorkspaceIntegration {
  datasourceAmount?: long(name='datasourceAmount'),
  integrationId?: string(name='integrationId'),
  integrationName?: string(name='integrationName'),
  previews?: [
    GrafanaWorkspaceIntegrationPreview
  ](name='previews'),
  status?: string(name='status'),
  supportRegions?: [ string ](name='supportRegions'),
}

model GrafanaWorkspaceIntegrationDataSource {
  clusterType?: string(name='clusterType'),
  datasourceId?: string(name='datasourceId'),
  datasourceName?: string(name='datasourceName'),
  datasourceUrl?: string(name='datasourceUrl'),
  description?: string(name='description'),
  exploreUrl?: string(name='exploreUrl'),
  folderUrl?: string(name='folderUrl'),
  regionId?: string(name='regionId'),
  status?: string(name='status'),
  type?: string(name='type'),
}

model GrafanaWorkspaceIntegrationDetail {
  dataSources?: [
    GrafanaWorkspaceIntegrationDataSource
  ](name='dataSources'),
  integrationId?: string(name='integrationId'),
  status?: string(name='status'),
}

model GrafanaWorkspaceIntegrationPreview {
  id?: string(name='id'),
  image?: string(name='image'),
  name?: string(name='name'),
  thumbnail?: string(name='thumbnail'),
}

model GrafanaWorkspaceNews {
  date?: long(name='date'),
  description?: string(name='description'),
  image?: string(name='image'),
  link?: string(name='link'),
  title?: string(name='title'),
}

model GrafanaWorkspaceOperateLog {
  date?: float(name='date'),
  detail?: string(name='detail'),
  grafanaWorkspaceId?: string(name='grafanaWorkspaceId'),
  id?: long(name='id'),
  operatorId?: string(name='operatorId'),
}

model GrafanaWorkspaceOrg {
  id?: long(name='id', example='1'),
  name?: string(name='name', example='main org'),
}

model GrafanaWorkspaceTrans {
  apiUrl?: string(name='apiUrl'),
  authType?: string(name='authType'),
  gmtCreate?: float(name='gmtCreate'),
  gmtModified?: float(name='gmtModified'),
  grafanaWorkspaceId?: string(name='grafanaWorkspaceId'),
  id?: long(name='id'),
  msg?: string(name='msg'),
  processStatus?: string(name='processStatus'),
  transDetails?: [
    GrafanaWorkspaceTransDetail
  ](name='transDetails'),
  userId?: string(name='userId'),
}

model GrafanaWorkspaceTransDetail {
  dashboardAmount?: int32(name='dashboardAmount'),
  dataSourceAmount?: int32(name='dataSourceAmount'),
  original?: long(name='original'),
  originalName?: string(name='originalName'),
  target?: long(name='target'),
  targetName?: string(name='targetName'),
}

model GrafanaWorkspaceUserCert {
  id?: string(name='id', example='8096753'),
  name?: string(name='name', example='cert-7700050 [grafana.tongtong-max.cn]'),
}

model GrafanaWorkspaceUserOrg {
  orgId?: long(name='orgId', example='1'),
  orgName?: string(name='orgName', example='main org'),
  role?: string(name='role', example='admin'),
}

model GrafanaWorkspaceVpcConfig {
  fcConfig?: string(name='fcConfig', example='fc、ansm'),
  id?: long(name='id', example='1'),
  installMsg?: string(name='installMsg'),
  installStatus?: string(name='installStatus', example='CreateSucceed'),
  name?: string(name='name', example='北京VPC-A通道'),
  regionId?: string(name='regionId', example='cn-beijing'),
  securityGroupId?: string(name='securityGroupId', example='sg-6we94uvybteyc******'),
  userId?: string(name='userId', example='10983***********'),
  vSwitchId?: string(name='vSwitchId', example='vsw-6we3**********'),
  vpcId?: string(name='vpcId', example='vpc-6wehr2x**********'),
}

model GrafanaWorkspaceVpcRegion {
  regionId?: string(name='regionId', example='cn-beijing'),
  regionName?: string(name='regionName', example='华北2（北京）'),
}

model GrafanaWorkspaceVpcRegionDetail {
  fcConfig?: string(name='fcConfig', example='fc、ansm'),
  id?: long(name='id', example='配置ID'),
  installStatus?: string(name='installStatus', example='Uninitialized'),
  name?: string(name='name', example='vpc-abc*****'),
  regionId?: string(name='regionId', example='cn-beijing'),
  securityGroupId?: string(name='securityGroupId'),
  securityGroupIds?: [ string ](name='securityGroupIds'),
  userId?: string(name='userId', example='10988**********'),
  vSwitchId?: string(name='vSwitchId'),
  vSwitchIds?: [ string ](name='vSwitchIds'),
  vpcId?: string(name='vpcId', example='vpc-2ze4siu98**********'),
}

model ARMSQueryDataSetRequest {
  datasetId?: long(name='DatasetId'),
  dateStr?: string(name='DateStr'),
  dimensions?: [ 
    {
      key?: string(name='Key'),
      type?: string(name='Type'),
      value?: string(name='Value'),
    }
  ](name='Dimensions'),
  hackerUserId?: string(name='HackerUserId'),
  hungryMode?: boolean(name='HungryMode'),
  intervalInSec?: int32(name='IntervalInSec'),
  isDrillDown?: boolean(name='IsDrillDown'),
  limit?: int32(name='Limit'),
  maxTime?: long(name='MaxTime'),
  measures?: [ string ](name='Measures'),
  minTime?: long(name='MinTime'),
  optionalDims?: [ 
    {
      key?: string(name='Key'),
      type?: string(name='Type'),
      value?: string(name='Value'),
    }
  ](name='OptionalDims'),
  orderByKey?: string(name='OrderByKey'),
  reduceTail?: boolean(name='ReduceTail'),
  requiredDims?: [ 
    {
      key?: string(name='Key'),
      type?: string(name='Type'),
      value?: string(name='Value'),
    }
  ](name='RequiredDims'),
  securityToken?: string(name='SecurityToken'),
}

model ARMSQueryDataSetResponseBody = {
  data?: string(name='Data'),
  requestId?: string(name='RequestId'),
}

model ARMSQueryDataSetResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: ARMSQueryDataSetResponseBody(name='body'),
}

async function aRMSQueryDataSetWithOptions(request: ARMSQueryDataSetRequest, runtime: Util.RuntimeOptions): ARMSQueryDataSetResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.datasetId)) {
    query['DatasetId'] = request.datasetId;
  }
  if (!Util.isUnset(request.dateStr)) {
    query['DateStr'] = request.dateStr;
  }
  if (!Util.isUnset(request.dimensions)) {
    query['Dimensions'] = request.dimensions;
  }
  if (!Util.isUnset(request.hackerUserId)) {
    query['HackerUserId'] = request.hackerUserId;
  }
  if (!Util.isUnset(request.hungryMode)) {
    query['HungryMode'] = request.hungryMode;
  }
  if (!Util.isUnset(request.intervalInSec)) {
    query['IntervalInSec'] = request.intervalInSec;
  }
  if (!Util.isUnset(request.isDrillDown)) {
    query['IsDrillDown'] = request.isDrillDown;
  }
  if (!Util.isUnset(request.limit)) {
    query['Limit'] = request.limit;
  }
  if (!Util.isUnset(request.maxTime)) {
    query['MaxTime'] = request.maxTime;
  }
  if (!Util.isUnset(request.measures)) {
    query['Measures'] = request.measures;
  }
  if (!Util.isUnset(request.minTime)) {
    query['MinTime'] = request.minTime;
  }
  if (!Util.isUnset(request.optionalDims)) {
    query['OptionalDims'] = request.optionalDims;
  }
  if (!Util.isUnset(request.orderByKey)) {
    query['OrderByKey'] = request.orderByKey;
  }
  if (!Util.isUnset(request.reduceTail)) {
    query['ReduceTail'] = request.reduceTail;
  }
  if (!Util.isUnset(request.requiredDims)) {
    query['RequiredDims'] = request.requiredDims;
  }
  if (!Util.isUnset(request.securityToken)) {
    query['SecurityToken'] = request.securityToken;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ARMSQueryDataSet',
    version = '2018-10-15',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function aRMSQueryDataSet(request: ARMSQueryDataSetRequest): ARMSQueryDataSetResponse {
  var runtime = new Util.RuntimeOptions{};
  return aRMSQueryDataSetWithOptions(request, runtime);
}

model MetricQueryRequest {
  dimensions?: [ string ](name='Dimensions'),
  endTime?: long(name='EndTime'),
  filters?: [ 
    {
      key?: string(name='Key'),
      value?: string(name='Value'),
    }
  ](name='Filters'),
  hackerUserId?: string(name='HackerUserId'),
  iintervalInSec?: int32(name='IintervalInSec'),
  limit?: int32(name='Limit'),
  measures?: [ string ](name='Measures'),
  metric?: string(name='Metric'),
  order?: string(name='Order'),
  orderBy?: string(name='OrderBy'),
  securityToken?: string(name='SecurityToken'),
  startTime?: long(name='StartTime'),
}

model MetricQueryResponseBody = {
  data?: string(name='Data'),
  requestId?: string(name='RequestId'),
}

model MetricQueryResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: MetricQueryResponseBody(name='body'),
}

async function metricQueryWithOptions(request: MetricQueryRequest, runtime: Util.RuntimeOptions): MetricQueryResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.dimensions)) {
    query['Dimensions'] = request.dimensions;
  }
  if (!Util.isUnset(request.endTime)) {
    query['EndTime'] = request.endTime;
  }
  if (!Util.isUnset(request.filters)) {
    query['Filters'] = request.filters;
  }
  if (!Util.isUnset(request.hackerUserId)) {
    query['HackerUserId'] = request.hackerUserId;
  }
  if (!Util.isUnset(request.iintervalInSec)) {
    query['IintervalInSec'] = request.iintervalInSec;
  }
  if (!Util.isUnset(request.limit)) {
    query['Limit'] = request.limit;
  }
  if (!Util.isUnset(request.measures)) {
    query['Measures'] = request.measures;
  }
  if (!Util.isUnset(request.metric)) {
    query['Metric'] = request.metric;
  }
  if (!Util.isUnset(request.order)) {
    query['Order'] = request.order;
  }
  if (!Util.isUnset(request.orderBy)) {
    query['OrderBy'] = request.orderBy;
  }
  if (!Util.isUnset(request.securityToken)) {
    query['SecurityToken'] = request.securityToken;
  }
  if (!Util.isUnset(request.startTime)) {
    query['StartTime'] = request.startTime;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'MetricQuery',
    version = '2018-10-15',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function metricQuery(request: MetricQueryRequest): MetricQueryResponse {
  var runtime = new Util.RuntimeOptions{};
  return metricQueryWithOptions(request, runtime);
}

